// 
// Decompiled by Procyon v0.5.36
// 

package com.orange.boot.dev3.controller;

import org.springframework.web.bind.annotation.DeleteMapping;
import java.io.Serializable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.orange.boot.dev3.entity.Insecticide;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.ApiOperation;
import com.orange.boot.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import com.orange.boot.dev3.service.InsecticideService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/orange_service/insecticide"})
@Api(
        tags = {"科学用药板块"}
)
public class InsecticideController {
    @Autowired
    private InsecticideService insecticideService;

    public InsecticideController() {
    }

    @ApiOperation("根据杀虫剂名，返回杀虫剂的基本信息")
    @GetMapping({"getpicAndName/{insecticideName}"})
    public R getInsecticideVo(String insecticideName) {
        return this.insecticideService.getInsecticideVo(insecticideName);
    }

    @ApiOperation("根据疾病名，返回所需杀虫剂")
    @GetMapping({"getInsecticide/{diseaseName}"})
    public R getInsecticide(String diseaseName) {
        return this.insecticideService.getInsecticide(diseaseName);
    }

    @ApiOperation("分页展示，返回各种病所需杀虫剂")
    @GetMapping({"getAllInsecticide/{current}/{size}"})
    public R getAllInsecticide(@PathVariable Long current, @PathVariable Long size) {
        return this.insecticideService.getAllInsecticide(current, size);
    }

    @ApiOperation("根据疾病名，返回对应杀虫剂的详细信息")
    @GetMapping({"getInsecticideInfo/{insecticideName}"})
    public R getInsecticideInfo(String diseaseName) {
        return this.insecticideService.getInsecticideInfo(diseaseName);
    }

    @ApiOperation("新增药剂信息")
    @PostMapping({"insertInsecticide"})
    public R insertInsecticide(@RequestBody Insecticide insecticide) {
        boolean save = this.insecticideService.save(insecticide);
        return save ? R.ok() : R.error("新增失败");
    }

    @ApiOperation("修改药剂信息")
    @PutMapping({"/updateInsecticide"})
    public R updateInsecticide(@RequestBody Insecticide insecticide) {
        return this.insecticideService.updateById(insecticide) ? R.ok().message("修改成功") : R.error("修改失败");
    }

    @ApiOperation("删除药剂")
    @DeleteMapping({"/deleteInsecticide/{id}"})
    public R deleteInsecticide(@PathVariable String id) {
        return this.insecticideService.removeById(id) ? R.ok().message("删除成功") : R.error("删除失败");
    }
}